package com.eques.demo.adapter.viewhoder

import android.content.Context
import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.eques.bean.Alarm
import com.eques.demo.R
import com.eques.util.EquesMytool


@Suppress("DEPRECATION")
class AlarmDetailHoder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {

    private val tv_animal_hours: TextView = itemView!!.findViewById(R.id.tv_animal_hours)
    private val view_top_line: View = itemView!!.findViewById(R.id.view_top_line)
    private val view_bottom_line: View = itemView!!.findViewById(R.id.view_bottom_line)
    private val tv_animal_content: TextView = itemView!!.findViewById(R.id.tv_animal_content)


    fun setData(context: Context, tabE1ProAlarmMsgInfo: List<Alarm>, position:Int) {
        tv_animal_hours.text =EquesMytool(context).getHD(tabE1ProAlarmMsgInfo[position].create_time)
        val alarmType: Int = tabE1ProAlarmMsgInfo[position].alarm
        var textStr:String?=null
        view_top_line.visibility =View.VISIBLE
        if(position==0){
            view_top_line.visibility =View.GONE
        }
        if(position==tabE1ProAlarmMsgInfo.size-1){
            view_bottom_line.visibility =View.GONE
        }
        when(alarmType){
            5->{
                textStr=context.getString(R.string.animal_alarm_hint5)
            }
            101->{
                textStr=context.getString(R.string.animal_alarm_hint1)
            }
            102->{
                textStr=context.getString(R.string.animal_alarm_hint2)
            }
            103->{
                textStr=context.getString(R.string.animal_alarm_hint3)
            }
            104->{
                textStr=context.getString(R.string.animal_alarm_hint4)
            }
            105->{
                textStr=context.getString(R.string.animal_alarm_hint6)
            }
        }
        tv_animal_content.text =textStr
    }
}